<template>
	<view>
		<view @click="search">
			<uni-view data-v-cf183850="" class="cu-bar search bg-white">
				<uni-view data-v-cf183850="" class="search-form round">
					<uni-text data-v-cf183850="" class="cuIcon-search"><span></span></uni-text>
					<uni-input data-v-cf183850="">
						<div class="uni-input-wrapper">
							<div class="uni-input-placeholder input-placeholder" data-v-cf183850="">搜索商品，请输入关键字</div>
							<!---->
							<form action="" class="uni-input-form"><input maxlength="140" step="" enterkeyhint="search"
									autocomplete="off" type="search" class="uni-input-input"></form>
						</div>
					</uni-input>
				</uni-view>
				<uni-view data-v-cf183850="" class="action">
					<uni-button data-v-cf183850="" class="cu-btn bg-green shadow-blur round">搜索</uni-button>
				</uni-view>
			</uni-view>
		</view>
		<view>
			<uni-view data-v-137708e8="" class="flex text-center">
				<uni-view data-v-137708e8="" data-id="0" class="cu-item flex-sub text-orange cur" @click='drugs'>药品</uni-view>
				<uni-view data-v-137708e8="" data-id="1" class="cu-item flex-sub" @click='Nutrition'>营养品</uni-view>
				<uni-view data-v-137708e8="" data-id="2" class="cu-item flex-sub" @click='healthProducts'>保健品</uni-view>
			</uni-view>
		</view>
		<view>
			<uni-input class="uni-page-head-search-input" style="color: rgb(0, 0, 0);">
				<div class="uni-input-wrapper">
					<div class="uni-input-placeholder input-placeholder" style="color: rgb(96, 98, 102);"></div>
					<!---->
					<form action="" class="uni-input-form"><input disabled="disabled" maxlength="140" step=""
							enterkeyhint="search" autocomplete="off" type="search" class="uni-input-input"></form>
				</div>
			</uni-input>
		</view>
		<view  style="width: 500rpx;">
			 <template v-for="(item,index) in goodsDate" >
				<view @click='details(item)'>
					名称：{{item.goodsName}}
				</view>
			 </template> 
		</view>
	</view>
</template>

<script>
	export default {
		onLoad() {
			this.drugs();
		},
		onShow(){
			this.$req.getGoodsByCategory('药品',0,3).then(res=>{
				console.log(res);
				this.goodsDate = res.data;
			})
		},
		data() {
			return {
				goodsDate:[
				],
				goodsId:''
			}
		},
		methods: {
			search() {
				uni.navigateTo({
					url: './search'
				})
			},
			backToUploadVideo(item){
				uni.setStorageSync("goodsForVideo",item);
				uni.navigateBack({
				})
			},
			details(item){
				uni.showModal({
					title: '选择商品',
					content: '确定选择该商品？',
					success: (res)=>{
						if (res.confirm) {
							this.backToUploadVideo(item);
						} else if (res.cancel) {
						}
					}
				});
			},
			drugs(){
				this.$req.getGoodsByCategory('药品',0,3).then(res=>{
					console.log(res);
					this.goodsDate = res.data;
				})
			},
			Nutrition(){
				this.$req.getGoodsByCategory('营养品',0,3).then(res=>{
					console.log(res);
					this.goodsDate = res.data;
				})
			},
			healthProducts(){
				this.$req.getGoodsByCategory('保健品',0,3).then(res=>{
					console.log(res);
					this.goodsDate = res.data;
				})
			}
		}
	}
</script>

<style>

</style>
